@echo on
setlocal
set exit=

if not defined DELPHI call :getdelphi
if defined exit exit /b %errorlevel%
"%DELPHI%\bin\dcc32" -U..\DCU32INT -B -Q -H- -W- dculib.dpr
if errorlevel 1 exit /b %errorlevel%
copy dculib.dll ..\dprutils
goto :EOF

:getdelphi
for /f "tokens=1,2,*" %%f in ('reg query HKLM\Software\Borland\Delphi /s 2^>nul') do @if "%%f"=="RootDir" set DELPHI=%%h
if "%DELPHI%"=="" (set error=Could not find any Delphi version in the Windows registry&& goto die)
goto :EOF

:die
set exit=1
echo Error: %error%
exit /b 2
